/*
 * Alloy Analyzer
 * Copyright (c) 2002 Massachusetts Institute of Technology
 *
 * The Alloy Analyzer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * The Alloy Analyzer is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with the Alloy Analyzer; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package alloy.symm;

import java.util.Set;

import alloy.transl.ASTInfo;
import alloy.transl.RelationAllocator;
import alloy.type.BasicType;

/**
 * Abstract base class for various symmetry-breaking methods.
 * Each implementation represents a particular way of utilizing
 * the interchangeability of atoms of a {@link BasicType} to
 * break symmetries.
 * <p>
 * Note: Most methods in this class take {@link AvailableSymmetry} argument that
 * contains the available symmetry information for all {@link BasicType}s,
 * but they only read/modify the symmetry information for the single {@link BasicType}
 * passed to the method.
 */
abstract class SymmetryBreakingMethod {
    /** Information about the translatable AST. */
    protected final ASTInfo _astInfo;

    /**
     * Relation allocator that allocated Boolean variables for all relations.
     * We need this because the symmetry-breaking predicates are expressed as
     * Boolean constraints over these variables, and we need to know which
     * Boolean variables have been allocated to which tuples of which relations.
     */
    protected final RelationAllocator _relAlloc;

    //////////////
    // Methods //
    ////////////
    
    protected SymmetryBreakingMethod(ASTInfo astInfo_, RelationAllocator relAlloc_) {
	_astInfo = astInfo_;
	_relAlloc = relAlloc_;
    }

    /**
     * Return a {@link SymmetryBreakingPredicate} for the given {@link BasicType},
     * and update the available symmetry information accordingly.  Implementations of
     * this method can assume that {@link #canBreakSymmetry} has already returned <code>true</code>
     * for this {@link AvailableSymmetry} and {@link BasicType}.
     */
    abstract SymmetryBreakingPredicate breakSymmetry(AvailableSymmetry availSymm_,
						     Set /* of BasicType */ basicTypes_);

}  // class SymmetryBreakingMethod

